home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1049 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  51 lines

  1. Newsgroups: comp.lang.c
  2. Path: netcom.com!ERICKPAR
  3. From: erk@netcom.com (Staugher)
  4. Subject: How to dynamically allocate first element of linked list.
  5. Message-ID: <erkDL007G.rt@netcom.com>
  6. Sender: erk@netcom9.netcom.com
  7. Organization: Martians for Earth Colonization
  8. X-Newsreader: News Xpress Version 1.0 Beta #4
  9. Date: Thu, 11 Jan 1996 00:48:04 GMT
  10.  
  11. Im trying (without any luck )to write a function to allocate the first element 
  12. of a doubly linked list in C++. Unfortunately I learned data structures in 
  13. Pascal and have to port my knowledge (or lack of ) to C.
  14.  
  15. Here is my arrangement:
  16.  
  17.  
  18. struct elmnt
  19.     { char name[20];
  20.       char number[17];
  21.       struct elmnt *forward_pointer;
  22.       struct elmnt *reverse_pointer;
  23.     }
  24.  
  25. //======================================
  26.  
  27. main()
  28. {
  29. struct elmnt *list = newlist(void)
  30. }
  31.  
  32. //======================================
  33.  
  34. struct elmnt * newlist(void)
  35. {
  36. struct elmnt *newptr;
  37. newptr = malloc(sizeof(struct elmnt));
  38. return (newptr);
  39. }
  40.  
  41. //=======================================
  42.  
  43.  
  44. The compiler complains with an ERROR that it cannot convert
  45. (void *) to (elmnt *) in function newlist
  46.  
  47. I hope that the problem is obvious to someone :/
  48.  
  49. ADV thanks ANCE
  50.  
  51.